import { UserProfilesAPI } from "@/request/api"
export default {
    namespaced: true,
    state: {
        userInfo: {
            nickName: "",
            coin: 0,
            headImg: require("../../assets/img/userImg.f8bbec5e.png")
        },
        cartTotal: 0
    },
    getters: {
    },
    mutations: {
        changeUserInfo(state, payload) {
            state.userInfo = payload.userInfo
            state.cartTotal = payload.cartTotal
        },
        initUserInfo(state) {
            state.userInfo = {
                nickName: "",
                coin: 0,
                headImg: require("../../assets/img/userImg.f8bbec5e.png")
            }
            state.cartTotal = 0
        }
    },
    actions: {
        async asyncChangeUserInfo(context) {
            let user = await UserProfilesAPI()
            context.commit("changeUserInfo", user.data)
        }
    },
    modules: {
    }

}